home *** CD-ROM | disk | FTP | other *** search
Wrap
RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeetttt((((3333CCCC++++++++)))) NNNNaaaammmmeeee RWTPtrHashSet<T> - Rogue Wave library class SSSSyyyynnnnooooppppssssiiiissss #include <rw/tphset.h> unsigned hashFun(const T&); PPPPlllleeeeaaaasssseeee NNNNooootttteeee!!!! RWTPtrHashSet(hashFun) set; IIIIffff yyyyoooouuuu ddddoooo nnnnooootttt hhhhaaaavvvveeee tttthhhheeee SSSSttttaaaannnnddddaaaarrrrdddd CCCC++++++++ LLLLiiiibbbbrrrraaaarrrryyyy,,,, uuuusssseeee tttthhhheeee iiiinnnntttteeeerrrrffffaaaacccceeee ddddeeeessssccccrrrriiiibbbbeeeedddd hhhheeeerrrreeee.... OOOOtttthhhheeeerrrrwwwwiiiisssseeee,,,, uuuusssseeee tttthhhheeee iiiinnnntttteeeerrrrffffaaaacccceeee ttttoooo RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeetttt described in the Class Reference. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeetttt<<<<TTTT>>>> is a derived class of RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhTTTTaaaabbbblllleeee<<<<TTTT>>>> where the iiiinnnnsssseeeerrrrtttt(((()))) function has been overridden to accept only one item of a given value. Hence, each item in the collection will have a unique value. As with class RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhTTTTaaaabbbblllleeee<<<<TTTT>>>>,,,, you must supply a hashing function to the constructor. The class TTTT must have: well-defined equality semantics (TTTT::::::::ooooppppeeeerrrraaaattttoooorrrr========((((ccccoooonnnnsssstttt TTTT&&&&))))). PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee None EEEExxxxaaaammmmpppplllleeee This examples exercises a set of RRRRWWWWCCCCSSSSttttrrrriiiinnnnggggssss. #include <rw/tphset.h> #include <rw/cstring.h> #include <rw/rstream.h> main() { RWTPtrHashSet<RWCString> set(RWCString::hash); set.insert(new RWCString("one")); set.insert(new RWCString("two")); set.insert(new RWCString("three")); set.insert(new RWCString("one")); cout << set.entries() << endl; // Prints "3" set.clearAndDestroy(); return 0; } PPPPaaaaggggeeee 1111 RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeetttt((((3333CCCC++++++++)))) Program output: 3 PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrr RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeetttt<T>(unsigned (*hashFun)(const T&), size_t buckets = RWDEFAULT_CAPACITY); Constructs an empty hashing set. The first argument is a pointer to a user-defined hashing function for items of type TTTT.... The table will initally have bbbbuuuucccckkkkeeeettttssss buckets although this can be changed with member function rrrreeeessssiiiizzzzeeee(((()))). PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss RWTPtrHashSet<T>& UUUUnnnniiiioooonnnn((((const RWTPtrHashSet<T>& h); Computes the union of self and hhhh, modifying self and returning self. RWTPtrHashSet<T>& ddddiiiiffffffffeeeerrrreeeennnncccceeee((((const RWTPtrHashSet<T>& h); Computes the disjunction of self and hhhh, modifying self and returning self. RWTPtrHashSet<T>& iiiinnnntttteeeerrrrsssseeeeccccttttiiiioooonnnn((((const RWTPtrHashSet<T>& h); Computes the intersection of self and hhhh, modifying self and returning self. RWTPtrHashSet<T>& ssssyyyymmmmmmmmeeeettttrrrriiiiccccDDDDiiiiffffffffeeeerrrreeeennnncccceeee((((const RWTPtrHashSet<T>& h); Computes the symmetric difference between self and hhhh, modifying self and returning self. RWBoolean iiiissssSSSSuuuubbbbsssseeeettttOOOOffff((((const RWTPtrHashSet<T>& h) const; Returns TTTTRRRRUUUUEEEE if self is a subset of hhhh. PPPPaaaaggggeeee 2222 RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeetttt((((3333CCCC++++++++)))) RWBoolean iiiissssPPPPrrrrooooppppeeeerrrrSSSSuuuubbbbsssseeeettttOOOOffff((((const RWTPtrHashSet<T>& h) const; Returns TTTTRRRRUUUUEEEE if self is a proper subset of hhhh. RWBoolean iiiissssEEEEqqqquuuuiiiivvvvaaaalllleeeennnntttt((((const RWTPtrHashSet<T>& h) const; Returns TTTTRRRRUUUUEEEE if self and hhhh are identical. RWBoolean ooooppppeeeerrrraaaattttoooorrrr!!!!====(const RWTPtrHashSet<T>& h) const; Returns FFFFAAAALLLLSSSSEEEE if self and hhhh are identical. void aaaappppppppllllyyyy(void (*applyFun)(T*, void*), void* d); Inherited from class RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhTTTTaaaabbbblllleeee<<<<TTTT>>>>. void cccclllleeeeaaaarrrr(); Inherited from class RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhTTTTaaaabbbblllleeee<<<<TTTT>>>>. void cccclllleeeeaaaarrrrAAAAnnnnddddDDDDeeeessssttttrrrrooooyyyy(); Inherited from class RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhTTTTaaaabbbblllleeee<<<<TTTT>>>>. RWBoolean ccccoooonnnnttttaaaaiiiinnnnssss(const T* a) const; Inherited from class RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhTTTTaaaabbbblllleeee<<<<TTTT>>>>. size_t eeeennnnttttrrrriiiieeeessss() const; Inherited from class RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhTTTTaaaabbbblllleeee<<<<TTTT>>>>. T* ffffiiiinnnndddd(const T* target) const; PPPPaaaaggggeeee 3333 RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhSSSSeeeetttt((((3333CCCC++++++++)))) Inherited from class RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhTTTTaaaabbbblllleeee<<<<TTTT>>>>. void iiiinnnnsssseeeerrrrtttt(T* a); Redefined from class RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhTTTTaaaabbbblllleeee<<<<TTTT>>>> to allow an object of a given value to be inserted only once. RWBoolean iiiissssEEEEmmmmppppttttyyyy() const; Inherited from class RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhTTTTaaaabbbblllleeee<<<<TTTT>>>>. size_t ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(const T* a) const; Inherited from class RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhTTTTaaaabbbblllleeee<<<<TTTT>>>>. T* rrrreeeemmmmoooovvvveeee(const T* a); Inherited from class RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhTTTTaaaabbbblllleeee<<<<TTTT>>>>. size_t rrrreeeemmmmoooovvvveeeeAAAAllllllll(const T* a); Inherited from class RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhTTTTaaaabbbblllleeee<<<<TTTT>>>>. void rrrreeeessssiiiizzzzeeee(size_t N); Inherited from class RRRRWWWWTTTTPPPPttttrrrrHHHHaaaasssshhhhTTTTaaaabbbblllleeee<<<<TTTT>>>>. PPPPaaaaggggeeee 4444